package com.yunxin.server.config;

import com.yunxin.common.utils.SnowflakeKeyGenerator;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zero°
 * @since 2023-06-03
 */
@Configuration
public class AutoConfiguration {

    @Bean
    public SnowflakeKeyGenerator sequenceGenerator(@Value("${snowflake.data.center.id:1}") Long dataCenterId,
                                                   @Value("${snowflake.worker.id:1}") Long workerId) {
        return new SnowflakeKeyGenerator(dataCenterId, workerId);
    }

}
